package com.smart.smartdata;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

public class ListAdapter extends BaseQuickAdapter<MessageData, BaseViewHolder> {


    public ListAdapter( @Nullable List<MessageData> data) {
        super(R.layout.message_data_item, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, MessageData item) {
        helper.addOnClickListener(R.id.tv_delete);

        helper.setText(R.id.tv_name,item.name);
        helper.setText(R.id.tv_six,item.six);
        helper.setText(R.id.tv_wight,item.wight+"KG");
        helper.setText(R.id.tv_age,item.age);
        helper.setText(R.id.tv_height,item.height);
        helper.setText(R.id.tv_time,formatTime(item.testTime));
        helper.setText(R.id.tv_date,item.testDate);

    }

    private String  formatTime(long time){

        long s =time/1000;


        int ss = (int)s;

        if(ss < 60){
            return ss +" 秒";
        }

        int min = (int)(s/60);


        return min +"分钟";

    }




}
